{
  let $ = window.jQuery;

  class Summary {
    constructor(element, options) {
      this.$element = $(element);
      this.options = $.extend({}, this.$element.data(), options);
      this.$target = $(this.options.target);
    }

    run() {
      let $more_link = $('<a class="more" href="#">MORE</a>');
      $more_link.bind('click', (e) => {
        e.preventDefault();
        this.$element.addClass('hide');
        this.$target.removeClass('hide');
      });
      this.$element.append($more_link);

      let $less_link = $('<a class="less" href="#">LESS</a>');
      $less_link.bind('click', (e) => {
        e.preventDefault();
        this.$element.removeClass('hide');
        this.$target.addClass('hide');
      });
      this.$target.append($less_link);
    }
  }

  $.fn.summary_text = function(options) {
    return this.each(function(){
      let plugin = new Summary(this, options);
      plugin.run();
    });
  }

  $.fn.summary_text.Constructor = Summary;

  $(document).ready(() => {
    $('[data-toggle="summary_text"]').summary_text();
  });
}
